1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdrhhcwrap.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <hintids.hxx>
34 #include <svx/svditer.hxx>
35 #include <svx/svdotext.hxx>
36 #include <svx/editdata.hxx>
37 #include <svx/svdpagv.hxx>
38 #include <svx/svdogrp.hxx>
39 #include <sfx2/printer.hxx>
40 #include <svx/svdmodel.hxx>
41 #include <svx/langitem.hxx>
42 #include <com/sun/star/beans/XPropertySet.hpp>
43 #include <linguistic/lngprops.hxx>
44 #include <sfx2/sfxuno.hxx>
45 #include <svx/svdview.hxx>
46 #include <svx/unolingu.hxx>
47 #include <unotools/localedatawrapper.hxx>
48 #include <sdrhhcwrap.hxx>
51 #include <docsh.hxx> // " " "
53 #include <wrtsh.hxx> // MakeVisible
57 #include <dcontact.hxx> // Spelling von DrawObj
58 #include <doc.hxx> // " " "
62 using namespace ::com::sun::star
;
63 using ::rtl::OUString
;
65 //////////////////////////////////////////////////////////////////////
67 SdrHHCWrapper::SdrHHCWrapper( SwView
* pVw
,
68 LanguageType nSourceLanguage
, LanguageType nTargetLanguage
,
69 const Font
* pTargetFnt
,
70 sal_Int32 nConvOptions
,
71 sal_Bool bInteractive
) :
72 SdrOutliner(pVw
->GetDocShell()->GetDoc()->GetDrawModel()->
73 GetDrawOutliner().GetEmptyItemSet().GetPool(),
74 OUTLINERMODE_TEXTOBJECT
),
79 nOptions( nConvOptions
),
81 nSourceLang( nSourceLanguage
),
82 nTargetLang( nTargetLanguage
),
83 pTargetFont( pTargetFnt
),
84 bIsInteractive( bInteractive
)
86 SetRefDevice( pView
->GetDocShell()->GetDoc()->getPrinter( false ) );
88 MapMode
aMapMode (MAP_TWIP
);
89 SetRefMapMode(aMapMode
);
92 SetPaperSize( aSize
);
94 pOutlView
= new OutlinerView( this, &(pView
->GetEditWin()) );
95 pOutlView
->GetOutliner()->SetRefDevice(pView
->GetWrtShell().getIDocumentDeviceAccess()->getPrinter( false ));
97 // Hack: Es sollten alle SdrTextObj-Attribute an die EditEngine
98 // uebertragen werden.
99 pOutlView
->SetBackgroundColor( Color( COL_WHITE
) );
102 InsertView( pOutlView
);
103 Point
aPoint( 0, 0 );
104 Rectangle
aRect( aPoint
, aSize
);
105 pOutlView
->SetOutputArea( aRect
);
110 SdrHHCWrapper::~SdrHHCWrapper()
114 SdrView
*pSdrView
= pView
->GetWrtShell().GetDrawView();
115 ASSERT( pSdrView
, "SdrHHCWrapper without DrawView?" );
116 pSdrView
->SdrEndTextEdit( sal_True
);
117 SetUpdateMode(sal_False
);
118 pOutlView
->SetOutputArea( Rectangle( Point(), Size(1, 1) ) );
119 // SetPaperSize( Size(1, 1) );
123 RemoveView( pOutlView
);
128 void SdrHHCWrapper::StartTextConversion()
130 pOutlView
->StartTextConversion( nSourceLang
, nTargetLang
, pTargetFont
, nOptions
, bIsInteractive
, sal_True
);
134 sal_Bool
SdrHHCWrapper::ConvertNextDocument()
136 sal_Bool bNextDoc
= sal_False
;
140 SdrView
*pSdrView
= pView
->GetWrtShell().GetDrawView();
141 ASSERT( pSdrView
, "SdrHHCWrapper without DrawView?" );
142 pSdrView
->SdrEndTextEdit( sal_True
);
143 SetUpdateMode(sal_False
);
144 pOutlView
->SetOutputArea( Rectangle( Point(), Size(1, 1) ) );
145 SetPaperSize( Size(1, 1) );
150 sal_uInt16 n
= nDocIndex
;
152 while( !bNextDoc
&& ( pListIter
||
153 n
< pView
->GetDocShell()->GetDoc()->GetSpzFrmFmts()->Count() ) )
155 while( !pTextObj
&& pListIter
)
157 if( pListIter
->IsMore() )
159 SdrObject
* pSdrO
= pListIter
->Next();
160 if( pSdrO
&& pSdrO
->IsA( TYPE(SdrTextObj
) ) &&
161 ( (SdrTextObj
*) pSdrO
)->HasText() )
162 pTextObj
= (SdrTextObj
*) pSdrO
;
172 n
< pView
->GetDocShell()->GetDoc()->GetSpzFrmFmts()->Count() )
174 SwFrmFmt
* pFly
= (*pView
->GetDocShell()->GetDoc()->GetSpzFrmFmts())[ n
];
175 if( pFly
->IsA( TYPE(SwDrawFrmFmt
) ) )
177 SwClientIter
aIter( (SwFmt
&) *pFly
);
178 if( aIter
.First( TYPE(SwDrawContact
) ) )
180 SdrObject
* pSdrO
= ((SwDrawContact
*)aIter())->GetMaster();
183 if ( pSdrO
->IsA( TYPE(SdrObjGroup
) ) )
184 pListIter
= new SdrObjListIter( *pSdrO
, IM_DEEPNOGROUPS
);
185 else if( pSdrO
->IsA( TYPE(SdrTextObj
) ) &&
186 ( (SdrTextObj
*) pSdrO
)->HasText() )
187 pTextObj
= (SdrTextObj
*) pSdrO
;
195 OutlinerParaObject
* pParaObj
= pTextObj
->GetOutlinerParaObject();
199 SetPaperSize( pTextObj
->GetLogicRect().GetSize() );
200 SetText( *pParaObj
);
204 //!! update mode needs to be set to true otherwise
205 //!! the call to 'HasConvertibleTextPortion' will not always
206 //!! work correctly because the document may not be properly
207 //!! formatted when some information is accessed, and thus
208 //!! incorrect results get returned.
209 SetUpdateMode(sal_True
);
210 if (HasConvertibleTextPortion( nSourceLang
))
212 SdrView
*pSdrView
= pView
->GetWrtShell().GetDrawView();
213 ASSERT( pSdrView
, "SdrHHCWrapper without DrawView?" );
214 SdrPageView
* pPV
= pSdrView
->GetSdrPageView();
217 pOutlView
->SetOutputArea( Rectangle( Point(), Size(1,1)));
218 SetPaperSize( pTextObj
->GetLogicRect().GetSize() );
219 SetUpdateMode(sal_True
);
220 pView
->GetWrtShell().MakeVisible(pTextObj
->GetLogicRect());
222 pSdrView
->SdrBeginTextEdit(pTextObj
, pPV
, &pView
->GetEditWin(), sal_False
, this, pOutlView
, sal_True
, sal_True
);
225 SetUpdateMode(sal_False
);
237 //////////////////////////////////////////////////////////////////////