LibreOffice Module sw (master)  1
sdrhhcwrap.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <hintids.hxx>
21 #include <svx/svditer.hxx>
22 #include <svx/svdotext.hxx>
23 #include <editeng/editdata.hxx>
24 #include <svx/svdpagv.hxx>
25 #include <svx/svdogrp.hxx>
26 #include <sfx2/printer.hxx>
27 #include <svx/svdmodel.hxx>
28 #include <editeng/langitem.hxx>
29 #include <linguistic/lngprops.hxx>
30 #include <sfx2/sfxuno.hxx>
31 #include <svx/svdview.hxx>
32 #include <editeng/unolingu.hxx>
34 #include <drawdoc.hxx>
35 #include "sdrhhcwrap.hxx"
36 #include <frmfmt.hxx>
37 #include <docsh.hxx>
38 #include <wrtsh.hxx>
39 #include <view.hxx>
40 #include <dcontact.hxx>
41 #include <doc.hxx>
44 #include <docary.hxx>
45 #include <edtwin.hxx>
46 
47 using namespace ::com::sun::star;
48 
50  LanguageType nSourceLanguage, LanguageType nTargetLanguage,
51  const vcl::Font* pTargetFnt,
52  sal_Int32 nConvOptions,
53  bool bInteractive ) :
54  SdrOutliner(pVw->GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->
55  GetDrawOutliner().GetEmptyItemSet().GetPool(),
57  pView( pVw ),
58  pTextObj( nullptr ),
59  nOptions( nConvOptions ),
60  nDocIndex( 0 ),
61  nSourceLang( nSourceLanguage ),
62  nTargetLang( nTargetLanguage ),
63  pTargetFont( pTargetFnt ),
64  bIsInteractive( bInteractive )
65 {
66  SetRefDevice( pView->GetDocShell()->GetDoc()->getIDocumentDeviceAccess().getPrinter( false ) );
67 
68  MapMode aMapMode (MapUnit::MapTwip);
69  SetRefMapMode(aMapMode);
70 
71  Size aSize( 1, 1 );
72  SetPaperSize( aSize );
73 
74  pOutlView.reset( new OutlinerView( this, &(pView->GetEditWin()) ) );
75  pOutlView->GetOutliner()->SetRefDevice(pView->GetWrtShell().getIDocumentDeviceAccess().getPrinter( false ));
76 
77  // Hack: all SdrTextObj attributes should be transferred to EditEngine
78  pOutlView->SetBackgroundColor( COL_WHITE );
79 
80  InsertView( pOutlView.get() );
81  Point aPoint( 0, 0 );
82  tools::Rectangle aRect( aPoint, aSize );
83  pOutlView->SetOutputArea( aRect );
84 // SetText( NULL );
85  ClearModifyFlag();
86 }
87 
89 {
90  if (pTextObj)
91  {
92  SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
93  OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
94  pSdrView->SdrEndTextEdit( true );
95  SetUpdateMode(false);
96  pOutlView->SetOutputArea( tools::Rectangle( Point(), Size(1, 1) ) );
97  }
98  RemoveView( pOutlView.get() );
99  pOutlView.reset();
100 }
101 
103 {
104  pOutlView->StartTextConversion( nSourceLang, nTargetLang, pTargetFont, nOptions, bIsInteractive, true );
105 }
106 
108 {
109  bool bNextDoc = false;
110 
111  if ( pTextObj )
112  {
113  SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
114  OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
115  pSdrView->SdrEndTextEdit( true );
116  SetUpdateMode(false);
117  pOutlView->SetOutputArea( tools::Rectangle( Point(), Size(1, 1) ) );
118  SetPaperSize( Size(1, 1) );
119  Clear();
120  pTextObj = nullptr;
121  }
122 
123  const auto n = nDocIndex;
124 
125  std::list<SdrTextObj*> aTextObjs;
127  for (auto const& textObj : aTextObjs)
128  {
129  pTextObj = textObj;
130  if (textObj)
131  {
132  OutlinerParaObject* pParaObj = textObj->GetOutlinerParaObject();
133  if ( pParaObj )
134  {
135  SetPaperSize( textObj->GetLogicRect().GetSize() );
136  SetText( *pParaObj );
137 
138  ClearModifyFlag();
139 
145  SetUpdateMode(true);
146  if (HasConvertibleTextPortion( nSourceLang ))
147  {
148  SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
149  OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
150  SdrPageView* pPV = pSdrView->GetSdrPageView();
151  nDocIndex = n;
152  bNextDoc = true;
153  pOutlView->SetOutputArea( tools::Rectangle( Point(), Size(1,1)));
155  SetUpdateMode(true);
157 
158  pSdrView->SdrBeginTextEdit(pTextObj, pPV, &pView->GetEditWin(), false, this, pOutlView.get(), true, true);
159  }
160  else
161  SetUpdateMode(false);
162  }
163 
164  if ( !bNextDoc )
165  pTextObj = nullptr;
166  else
167  break;
168  }
169  }
170 
171  ClearModifyFlag();
172 
173  return bNextDoc;
174 }
175 
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OutlinerMode
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
SdrView * GetDrawView()
Definition: vnew.cxx:375
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:237
SwEditWin & GetEditWin()
Definition: view.hxx:403
const vcl::Font * pTargetFont
Definition: sdrhhcwrap.hxx:39
SwWrtShell & GetWrtShell() const
Definition: view.hxx:400
std::unique_ptr< OutlinerView > pOutlView
Definition: sdrhhcwrap.hxx:34
void MakeVisible(const SwRect &)
Definition: viewsh.cxx:578
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:203
const IDocumentDeviceAccess & getIDocumentDeviceAccess() const
Provides access to the document device interface.
Definition: viewsh.cxx:2593
virtual bool SdrBeginTextEdit(SdrObject *pObj, SdrPageView *pPV=nullptr, vcl::Window *pWin=nullptr, bool bIsNewObj=false, SdrOutliner *pGivenOutliner=nullptr, OutlinerView *pGivenOutlinerView=nullptr, bool bDontDeleteOutliner=false, bool bOnlyOneView=false, bool bGrabFocus=true)
LanguageType const nSourceLang
Definition: sdrhhcwrap.hxx:37
virtual SfxPrinter * getPrinter(bool bCreate) const =0
Return the printer set at the document.
sal_uInt16 nDocIndex
Definition: sdrhhcwrap.hxx:36
SdrHHCWrapper(SwView *pVw, LanguageType nSourceLanguage, LanguageType nTargetLanguage, const vcl::Font *pTargetFnt, sal_Int32 nConvOptions, bool bInteractive)
Definition: sdrhhcwrap.cxx:49
Size GetSize() const
SwDocShell * GetDocShell()
Definition: view.cxx:1128
void StartTextConversion()
Definition: sdrhhcwrap.cxx:102
SwView * pView
Definition: sdrhhcwrap.hxx:32
bool const bIsInteractive
Definition: sdrhhcwrap.hxx:40
SdrTextObj * pTextObj
Definition: sdrhhcwrap.hxx:33
sal_Int32 const nOptions
Definition: sdrhhcwrap.hxx:35
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
SdrPageView * GetSdrPageView() const
static void GetTextObjectsFromFormat(std::list< SdrTextObj * > &, SwDoc *)
get data collection of anchored objects, handled by with contact
Definition: dcontact.cxx:729
virtual ~SdrHHCWrapper() override
Definition: sdrhhcwrap.cxx:88
virtual bool ConvertNextDocument() override
Definition: sdrhhcwrap.cxx:107
Definition: view.hxx:146
virtual const tools::Rectangle & GetLogicRect() const override
LanguageType const nTargetLang
Definition: sdrhhcwrap.hxx:38