Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <hintids.hxx>
30 : : #include <svx/svditer.hxx>
31 : : #include <svx/svdotext.hxx>
32 : : #include <editeng/editdata.hxx>
33 : : #include <svx/svdpagv.hxx>
34 : : #include <svx/svdogrp.hxx>
35 : : #include <sfx2/printer.hxx>
36 : : #include <svx/svdmodel.hxx>
37 : : #include <editeng/langitem.hxx>
38 : : #include <com/sun/star/beans/XPropertySet.hpp>
39 : : #include <linguistic/lngprops.hxx>
40 : : #include <sfx2/sfxuno.hxx>
41 : : #include <svx/svdview.hxx>
42 : : #include <editeng/unolingu.hxx>
43 : : #include <unotools/localedatawrapper.hxx>
44 : : #include <sdrhhcwrap.hxx>
45 : : #include <frmfmt.hxx>
46 : : #include <docsh.hxx> // " " "
47 : : #include <wrtsh.hxx> // MakeVisible
48 : : #include <view.hxx>
49 : : #include <dcontact.hxx> // Spelling von DrawObj
50 : : #include <doc.hxx> // " " "
51 : : #include <docary.hxx>
52 : : #include <edtwin.hxx>
53 : :
54 : : using namespace ::com::sun::star;
55 : : using ::rtl::OUString;
56 : :
57 : : //////////////////////////////////////////////////////////////////////
58 : :
59 : 0 : SdrHHCWrapper::SdrHHCWrapper( SwView* pVw,
60 : : LanguageType nSourceLanguage, LanguageType nTargetLanguage,
61 : : const Font* pTargetFnt,
62 : : sal_Int32 nConvOptions,
63 : : sal_Bool bInteractive ) :
64 : 0 : SdrOutliner(pVw->GetDocShell()->GetDoc()->GetDrawModel()->
65 : 0 : GetDrawOutliner().GetEmptyItemSet().GetPool(),
66 : : OUTLINERMODE_TEXTOBJECT ),
67 : : pView( pVw ),
68 : : pTextObj( NULL ),
69 : : pOutlView( NULL ),
70 : : nOptions( nConvOptions ),
71 : : nDocIndex( 0 ),
72 : : nSourceLang( nSourceLanguage ),
73 : : nTargetLang( nTargetLanguage ),
74 : : pTargetFont( pTargetFnt ),
75 : 0 : bIsInteractive( bInteractive )
76 : : {
77 [ # # ][ # # ]: 0 : SetRefDevice( pView->GetDocShell()->GetDoc()->getPrinter( false ) );
[ # # ]
78 : :
79 [ # # ]: 0 : MapMode aMapMode (MAP_TWIP);
80 [ # # ]: 0 : SetRefMapMode(aMapMode);
81 : :
82 : 0 : Size aSize( 1, 1 );
83 [ # # ]: 0 : SetPaperSize( aSize );
84 : :
85 [ # # ][ # # ]: 0 : pOutlView = new OutlinerView( this, &(pView->GetEditWin()) );
86 [ # # ][ # # ]: 0 : pOutlView->GetOutliner()->SetRefDevice(pView->GetWrtShell().getIDocumentDeviceAccess()->getPrinter( false ));
[ # # ]
87 : :
88 : : // Hack: all SdrTextObj attributes should be transferred to EditEngine
89 [ # # ]: 0 : pOutlView->SetBackgroundColor( Color( COL_WHITE ) );
90 : :
91 : :
92 [ # # ]: 0 : InsertView( pOutlView );
93 : 0 : Point aPoint( 0, 0 );
94 [ # # ]: 0 : Rectangle aRect( aPoint, aSize );
95 [ # # ]: 0 : pOutlView->SetOutputArea( aRect );
96 : : // SetText( NULL );
97 [ # # ][ # # ]: 0 : ClearModifyFlag();
98 : 0 : }
99 : :
100 : 0 : SdrHHCWrapper::~SdrHHCWrapper()
101 : : {
102 [ # # ]: 0 : if (pTextObj)
103 : : {
104 [ # # ]: 0 : SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
105 : : OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
106 [ # # ]: 0 : pSdrView->SdrEndTextEdit( sal_True );
107 [ # # ]: 0 : SetUpdateMode(sal_False);
108 [ # # ][ # # ]: 0 : pOutlView->SetOutputArea( Rectangle( Point(), Size(1, 1) ) );
109 : : }
110 [ # # ]: 0 : RemoveView( pOutlView );
111 [ # # ][ # # ]: 0 : delete pOutlView;
112 [ # # ]: 0 : }
113 : :
114 : :
115 : 0 : void SdrHHCWrapper::StartTextConversion()
116 : : {
117 : 0 : pOutlView->StartTextConversion( nSourceLang, nTargetLang, pTargetFont, nOptions, bIsInteractive, sal_True );
118 : 0 : }
119 : :
120 : :
121 : 0 : sal_Bool SdrHHCWrapper::ConvertNextDocument()
122 : : {
123 : 0 : sal_Bool bNextDoc = sal_False;
124 : :
125 [ # # ]: 0 : if ( pTextObj )
126 : : {
127 [ # # ]: 0 : SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
128 : : OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
129 [ # # ]: 0 : pSdrView->SdrEndTextEdit( sal_True );
130 [ # # ]: 0 : SetUpdateMode(sal_False);
131 [ # # ][ # # ]: 0 : pOutlView->SetOutputArea( Rectangle( Point(), Size(1, 1) ) );
132 [ # # ]: 0 : SetPaperSize( Size(1, 1) );
133 [ # # ]: 0 : Clear();
134 : 0 : pTextObj = NULL;
135 : : }
136 : :
137 : 0 : sal_uInt16 n = nDocIndex;
138 : :
139 [ # # ]: 0 : std::list<SdrTextObj*> aTextObjs;
140 [ # # ][ # # ]: 0 : SwDrawContact::GetTextObjectsFromFmt( aTextObjs, pView->GetDocShell()->GetDoc() );
141 [ # # ][ # # ]: 0 : for ( std::list<SdrTextObj*>::iterator aIt = aTextObjs.begin(); aIt != aTextObjs.end(); ++aIt )
[ # # ]
142 : : {
143 [ # # ]: 0 : pTextObj = (*aIt);
144 [ # # ]: 0 : if ( pTextObj )
145 : : {
146 [ # # ]: 0 : OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
147 [ # # ]: 0 : if ( pParaObj )
148 : : {
149 [ # # ][ # # ]: 0 : SetPaperSize( pTextObj->GetLogicRect().GetSize() );
[ # # ]
150 [ # # ]: 0 : SetText( *pParaObj );
151 : :
152 [ # # ]: 0 : ClearModifyFlag();
153 : :
154 : : //!! update mode needs to be set to true otherwise
155 : : //!! the call to 'HasConvertibleTextPortion' will not always
156 : : //!! work correctly because the document may not be properly
157 : : //!! formatted when some information is accessed, and thus
158 : : //!! incorrect results get returned.
159 [ # # ]: 0 : SetUpdateMode(sal_True);
160 [ # # ][ # # ]: 0 : if (HasConvertibleTextPortion( nSourceLang ))
161 : : {
162 [ # # ]: 0 : SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
163 : : OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
164 : 0 : SdrPageView* pPV = pSdrView->GetSdrPageView();
165 : 0 : nDocIndex = n;
166 : 0 : bNextDoc = sal_True;
167 [ # # ][ # # ]: 0 : pOutlView->SetOutputArea( Rectangle( Point(), Size(1,1)));
168 [ # # ][ # # ]: 0 : SetPaperSize( pTextObj->GetLogicRect().GetSize() );
[ # # ]
169 [ # # ]: 0 : SetUpdateMode(sal_True);
170 [ # # ][ # # ]: 0 : pView->GetWrtShell().MakeVisible(pTextObj->GetLogicRect());
[ # # ]
171 : :
172 [ # # ]: 0 : pSdrView->SdrBeginTextEdit(pTextObj, pPV, &pView->GetEditWin(), sal_False, this, pOutlView, sal_True, sal_True);
173 : : }
174 : : else
175 [ # # ]: 0 : SetUpdateMode(sal_False);
176 : : }
177 : :
178 [ # # ]: 0 : if ( !bNextDoc )
179 : 0 : pTextObj = NULL;
180 : : else
181 : 0 : break;
182 : : }
183 : : }
184 : :
185 [ # # ]: 0 : ClearModifyFlag();
186 : :
187 : 0 : return bNextDoc;
188 : : }
189 : :
190 : : //////////////////////////////////////////////////////////////////////
191 : :
192 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|